#ifndef CPEVENDORHUAWEI_H
#define CPEVENDORHUAWEI_H

/* 自身头文件 */
#include "interfaceplugin.h"
#include "interfacevendor.h"
#include "cpedefine.h"
/* 系统库 */
#include <QWidget>
#include <QtPlugin>
#include <QTimer>
#include <QMutex>

QT_BEGIN_NAMESPACE
namespace Ui
{
class CpeVendorHUAWEI;
}
QT_END_NAMESPACE

class CpeVendorHUAWEI : public QWidget, InterfacePlugin, InterfaceVendor
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "com.kk.cpemanager.cpevendorhuawei" FILE "cpevendorhuawei.json")
    Q_INTERFACES(InterfacePlugin)
    Q_INTERFACES(InterfaceVendor)
public:
    CpeVendorHUAWEI();

    /**
     * @brief startPlugin 启动插件
     */
    void startPlugin() override;

    /**
    * @brief recognize 识别设备，判断厂家一致性
    */
    void recognize() override;

    /**
     * @brief logout 退出登录
     */
    void logout() override;

    void reboot() override;

    void setRat(const QString &strRat) override;

    void refreshOnce() override;

    void setBandLock(const std::vector<int> &vecCGW, const std::vector<int> &vecLTE, const std::vector<int> &vecNR, int iType) override;

    /**
     * @brief setLTECellLock    执行LTE锁小区 or 锁频点
     * @param strEARFCN         EARFCN  必填
     * @param strPCI            PCI     选填
     */
    void setLTECellLock(const QString &strEARFCN, const QString &strPCI = "") override;

    void unlockBandLock(CpeEmUnlockBandType eType) override;
    /**
     * @brief setNRCellLock     执行NR锁小区 or 锁频点
     * @param strEARFCN         EARFCN  必填
     * @param strPCI            PCI     选填
     * @param strBand           Band    选填
     * @param strSCS            SCS     选填
     */
    void setNRCellLock(const QString &strEARFCN, const QString &strPCI = "", const QString &strBand = "", const QString &strSCS = "") override;

    void unlockLTECellLock() override;

    void unlockNRCellLock() override;

    void stopCycle() override;

    void get(const QString &strPlugin, int iInfoID, const QString &strUrl) override;
    void post(const QString &strPlugin, int iInfoID, const QString &strUrl, const QString &strPost) override;

public slots:
    void recMsgfromManager(PluginMetaData metadata) override;

signals:
    void sendMsg2Manager(PluginMetaData metadata) override;
    void cycleSignal();

private:
    void startCycle();
    void status(const QString &str);
    void plmn(const QString &str);
    void traffic(const QString &str);
    void signal(const QString &str);
    void cellInfo(const QString &str);
    void totalTraffic(const QString &str);
    void show2G();
    void show3G();
    void show4G();
    void showNR();
    void hideNR();
    void showSA();
    void hideLayout(QLayout *pLayout);
    void showLayout(QLayout *pLayout);
    QString NetTypetoStr(const QString &strType);
    QString connectMode(int nType);
    void postHelper();

private slots:
    void onCycle();
    void on_chkDataSwitch_clicked(bool checked);
    void on_chk5GAntenna_clicked(bool checked);
    void on_rdoInternal_clicked();
    void on_rdoMixed_clicked();
    void on_rdoAuto_clicked();
    void on_rdoExternal_clicked();

private:
    Ui::CpeVendorHUAWEI *ui;
    QString m_strIP, m_strUser, m_strPass;
    QString m_strToken, m_strUrl, m_strPost;
    int m_iInfoID;
    QString m_strCGW;
    QString m_hwRat, m_hwNROpt, m_hwCGW;
    QString m_hwLac, m_hwCid;
    bool m_bNrDevice;
    bool m_bNrPoint;
    bool m_bNrOption;
    bool m_bNoScs;
    QString m_hwNetType, m_hwNetTypeEx;
    QString m_strPlugin;
    QString m_strConnectType;
    QTimer m_timer;
    QMutex m_mutex;
};

#endif
